// import com.alibaba.druid.sql.ast.SQLExpr_ptr;
// import com.alibaba.druid.sql.ast.SQLName_ptr;
// import com.alibaba.druid.sql.ast.SQLReplaceable;
// import com.alibaba.druid.sql.ast.SQLStatementImpl;
// import com.alibaba.druid.sql.visitor.SQLASTVisitor;

#include "SQLShowCreateTableStatement.h"
#include "../../visitor/SQLASTVisitor.h"
#include "../SQLName.h"

void SQLShowCreateTableStatement::accept0(SQLASTVisitor_ptr visitor)
{
  if (visitor->visit(SharedObject(SQLShowCreateTableStatement)))
  {
    acceptChild(visitor, name);
    acceptChild(visitor, likeMapping);
  }
  visitor->endVisit(SharedObject(SQLShowCreateTableStatement));
}

SQLName_ptr SQLShowCreateTableStatement::getName()
{
  return name;
}

void SQLShowCreateTableStatement::setName(SQLName_ptr name)
{
  if (name != nullptr)
  {
    name->setParent(SharedObject(SQLShowCreateTableStatement));
  }
  this->name = name;
}

SQLName_ptr SQLShowCreateTableStatement::getLikeMapping()
{
  return likeMapping;
}

void SQLShowCreateTableStatement::setLikeMapping(SQLName_ptr likeMapping)
{
  this->likeMapping = likeMapping;
}

BOOL_ptr SQLShowCreateTableStatement::isAll()
{
  return all;
}

void SQLShowCreateTableStatement::setAll(BOOL_ptr all)
{
  this->all = all;
}

// @Override
BOOL_ptr SQLShowCreateTableStatement::replace(SQLExpr_ptr expr, SQLExpr_ptr target)
{
  if (name == expr)
  {
    setName(std::dynamic_pointer_cast<SQLName>(target));
    return BOOL::TRUE;
  }
  if (likeMapping == expr)
  {
    setLikeMapping(std::dynamic_pointer_cast<SQLName>(target));
    return BOOL::TRUE;
  }
  return BOOL::FALSE;
}
